package com.ruoyi.rest.controller;

import com.ruoyi.book.domain.Chapter;
import com.ruoyi.book.service.IChapterService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.rest.vo.ChapterVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 章节列表Controller
 * 
 * @author ruoyi
 * @date 2024-08-05
 */
@Anonymous
@RestController
@RequestMapping("/rest/book/chapter")
public class RestChapterController extends BaseController
{
    @Autowired
    private IChapterService ChapterService;

    /**
     * 查询章节列表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Chapter Chapter)
    {
        List<ChapterVo> list = ChapterService.selectChapterList(Chapter);
        return getDataTable(list);
    }


    /**
     * 获取章节列表详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ChapterService.selectChapterById(id));
    }

}
